package com.xiye.zuul.config;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 西野
 * @version V1.0
 * @title DocumentationConfig.java
 * @package com.xiye.zuul.config
 * @description 配置swagger文档资源
 * @date 2018-07-18
 */
@Component
@Primary
public class DocumentationConfig implements SwaggerResourcesProvider {

    /*
     * @Author 西野
     * @Date 2018-07-19 16:33:30
     * @Description zuul网关加载子项目中的api文档
     * @Param []
     * @Return java.util.List<springfox.documentation.swagger.web.SwaggerResource>
     */
    @Override
    public List<SwaggerResource> get() {
        List resources = new ArrayList<>();
        resources.add(swaggerResource("系统管理接口", "/xiye-system/v2/api-docs", "2.0"));
        resources.add(swaggerResource("检查系统接口", "/xiye-system/v2/api-docs", "2.0"));
        return resources;
    }

    private SwaggerResource swaggerResource(String name, String location, String version) {
        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }
}
